import java.util.ServiceConfigurationError;

/**
 * Created by Administrator on 2017/10/31.
 */
public class StackImpl implements Stack {
   private int top;
   private Object date[];
   private final int MAX_STACK=100;

    public StackImpl() {
        date=new Object[MAX_STACK];
        top=-1;
    }

    @Override
    public boolean isFull() {
        return top==MAX_STACK;
    }

    @Override
    public boolean isEmpty() {
        return top==-1;
    }

    @Override
    public void push(Object element) throws StackOverflowError {
        if(isFull())
        {
            throw new ServiceConfigurationError("栈已满");
        }
       date[top++]=element;
    }

    @Override
    public Object pop() {
        return date[top--];
    }

    @Override
    public Object show() {
       return date[top];
    }
}
